<?php
class m_sekolah extends MY_Model {
    public $table = "m_sekolah";
    public $id = "nomor_induk";
	
	public function get_jumlah_sekolah($jenis_id){
		$q = $this->db->query("Select count(ms.id) as jumlah, ms.kecamatan_id, ms.sekolah_status_id 
								from m_sekolah ms
								where ms.sekolah_jenis_id =$jenis_id
								group by ms.kecamatan_id, ms.sekolah_status_id ");
        $data = $q->result_array();
		$ret = array();
		foreach($data as $detail){
			$ret[$detail['kecamatan_id']][$detail['sekolah_status_id']] = $detail['jumlah'];
		}
		return $ret;
	}
	
	public function get_jumlah_sekolah_akreditasi($jenis_id){
		$q = $this->db->query("Select count(ms.id) as jumlah, ms.kecamatan_id, ms.sekolah_akreditasi_id 
								from m_sekolah ms
								where ms.sekolah_jenis_id =$jenis_id
								group by ms.kecamatan_id, ms.sekolah_akreditasi_id ");
        $data = $q->result_array();
		$ret = array();
		foreach($data as $detail){
			$ret[$detail['kecamatan_id']][$detail['sekolah_akreditasi_id']] = $detail['jumlah'];
		}
		return $ret;
	}
	
	public function get_jumlah_sekolah_standard($jenis_id){
		$q = $this->db->query("Select count(ms.id) as jumlah, ms.kecamatan_id, ms.sekolah_status_id, ms.sekolah_standard_id 
								from m_sekolah ms
								where ms.sekolah_jenis_id =$jenis_id
								group by ms.kecamatan_id, ms.sekolah_status_id, ms.sekolah_standard_id ");
        $data = $q->result_array();
		$ret = array();
		foreach($data as $detail){
			$ret[$detail['kecamatan_id']][$detail['sekolah_status_id']][$detail['sekolah_standard_id']] = $detail['jumlah'];
		}
		return $ret;
	}
}